home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 20 / Cream of the Crop 20 (Terry Blount) (1996).iso / program / n_b_v203.zip / SLIDER-2.DMO < prev    next >
Text File  |  1996-07-04  |  5KB  |  74 lines

  1. $if 0
  2.     ┌──────────────────────────╖                        PowerBASIC v3.20
  3.  ┌──┤          DASoft          ╟──────────────────────┬──────────────────╖
  4.  │  ├──────────────────────────╢    Copyright 1995    │ DATE: 1995-10-01 ╟─╖
  5.  │  │ FILE NAME   SLIDER-2.DMO ║          by          ╘════════════════─ ║ ║
  6.  │  │                          ║  Don Schullian, Jr.                     ║ ║
  7.  │  ╘══════════════════════════╝                                         ║ ║
  8.  │ A license is hereby granted to the holder to use this source code in  ║ ║
  9.  │ any program, commercial or otherwise,  without receiving the express  ║ ║
  10.  │ permission of the copyright holder and without paying any royalties,  ║ ║
  11.  │ as long as this code is not distributed in any compilable format.     ║ ║
  12.  │  IE: source code files, PowerBASIC Unit files, and printed listings   ║ ║
  13.  ╘═╤═════════════════════════════════════════════════════════════════════╝ ║
  14.    │                ....................................                   ║
  15.    ╘═══════════════════════════════════════════════════════════════════════╝
  16. $endif
  17.  
  18. '.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
  19. ' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
  20.  
  21. $INCLUDE "DAS-NBT1.INC"
  22. $INCLUDE "KEYCODES.INC"
  23.  
  24. COLOR 7, 0
  25. CLS
  26. ? "┌───────────────────────────────────────────────────────────────────
  27. ? "│ TsliderV2 ( Row?, Col?, Rows?, IpS?, Items%, FoS% )
  28. ? "├──────────────────────────────────────────────────────────────────────
  29. ? "│ This is menu position indicator. Items% is the total number of items
  30. ? "│ in the menu, IpS? are the number of items visible, and FoS% is the
  31. ? "│ first item number to appear on the screen.
  32. ? "│ For our demo we're simulating a menu with 50 items. You move through
  33. ? "│ the list using UP and DOWN. Press ESC to end the demo.
  34. ? "└─────────────────────────────────────────────────────────────────────────
  35.                                                    '┌───────────────────────
  36. TBoxDRAW   10, 17, 13, 16, 1, 15                   '│ a little menu box
  37. TBoxDRAWv  10, 30, 13,     1,  1                   '│ with a vert box right
  38. TBoxColor  11, 31, 11,  1,    10                   '│ a new attr in the v-box
  39. TBoxColor  16, 18,  1, 12,    31                   '│ and a selection bar
  40.                                                    '│
  41. Hot% = 1                                           '│ gotta start somewhere
  42. DO                                                 '│ menu? loop
  43.   Row? = 11                                        '│ reprint menu items
  44.   FOR I% = ( Hot% - 5 ) TO ( Hot% + 5 )            '│ I like my selection bar
  45.     IF ( I% < 1 ) OR ( I% > 50 ) THEN              '│ to stay in one place as
  46.         I$ = "░░░░░░░░░░"                          '│ it reduces eye strain
  47.       ELSE                                         '│ for the user
  48.         I$ = USING$( "Item N° ##", I% )            '│
  49.     END IF                                         '│
  50.     Tprint Row?, 19, I$, 0                         '│ Att? = 0 so I don't
  51.     INCR Row?, 1                                   '│ have to compute it
  52.   NEXT                                             '│
  53.   TsliderV2 11, 31, 11, 11, 50, Hot%               '│ reprint the slider
  54.   SELECT CASE fGetKey%                             '│ act on key-press
  55.     CASE %HOME_key   : Hot% = 1                    '│ top of list
  56.     CASE %UP_key     : Hot% = MAX(  1, Hot% -  1 ) '│ up one
  57.     CASE %PGUP_key   : Hot% = MAX(  1, Hot% - 10 ) '│ up a page full - 1
  58.     CASE %END_key    : Hot% = 50                   '│ end of the list
  59.     CASE %DOWN_key   : Hot% = MIN( 50, Hot% +  1 ) '│ down one
  60.     CASE %PGDN_key   : Hot% = MIN( 50, Hot% + 10 ) '│ down a page full -1
  61.     CASE %ENTER_key  : EXIT LOOP                   '│ all done!
  62.     CASE %ESC_key    : EXIT LOOP                   '│ <ditto>
  63.   END SELECT                                       '│
  64.                                                    '│
  65. LOOP                                               '│ dah...
  66. CLS                                                '│ did we just write a
  67. END                                                '│ whole menu function?
  68. ' ──────────────────────────────────────────────────┤
  69. FUNCTION fGetKey% LOCAL PUBLIC                     '│ seen this before?
  70.                                                    '│
  71.   WHILE NOT INSTAT : WEND                          '│
  72.   FUNCTION = CVI( INKEY$ + CHR$(0) )               '│
  73.                                                    '│
  74. END FUNCTION                                       '│